#!/bin/bash
set -xeuo pipefail
IMAGES=${1:-images/hub images/singleuser-sample}

# Because `pip-compile` resolves `requirements.txt` with the current
# Python for the current platform, it should be run on the same Python
# version and platform as our Dockerfile.

for img in ${IMAGES}; do
    pushd "$img"
    docker run --rm \
        --env=CUSTOM_COMPILE_COMMAND='Use the "Run workflow" button at https://github.com/jupyterhub/zero-to-jupyterhub-k8s/actions/workflows/watch-dependencies.yaml' \
        --volume="$PWD:/io" \
        --workdir=/io \
        --user=root \
        python:3.12-bookworm \
        sh -c 'pip install pip-tools==7.* && pip-compile --allow-unsafe --strip-extras --upgrade --output-file=requirements.txt unfrozen/requirements.txt'
    popd
done
